mm: Fix mremap not considering huge pmd devmap
authorFan Yang <Fan_Yang@sjtu.edu.cn>
Thu, 4 Jun 2020 10:22:07 +0000 (18:22 +0800)
committerBen Hutchings <benh@debian.org>
Tue, 9 Jun 2020 17:50:00 +0000 (18:50 +0100)
commit400fcc0b569a9944b0bee1f4e98a53d026b6bf49
treeca87b8de7fda44859f44d30a0d614826cd12b565
parenta3358df5277033e5b38fcfd719cc0b3827c5923f
mm: Fix mremap not considering huge pmd devmap

Origin: https://git.kernel.org/linus/5bfea2d9b17f1034a68147a8b03b9789af5700f9
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2020-10757

The original code in mm/mremap.c checks huge pmd by:

if (is_swap_pmd(*old_pmd) || pmd_trans_huge(*old_pmd)) {

However, a DAX mapped nvdimm is mapped as huge page (by default) but it
is not transparent huge page (_PAGE_PSE | PAGE_DEVMAP).  This commit
changes the condition to include the case.

This addresses CVE-2020-10757.

Fixes: 5c7fb56e5e3f ("mm, dax: dax-pmd vs thp-pmd vs hugetlbfs-pmd")
Cc: <stable@vger.kernel.org>
Reported-by: Fan Yang <Fan_Yang@sjtu.edu.cn>
Signed-off-by: Fan Yang <Fan_Yang@sjtu.edu.cn>
Tested-by: Fan Yang <Fan_Yang@sjtu.edu.cn>
Tested-by: Dan Williams <dan.j.williams@intel.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name mm-Fix-mremap-not-considering-huge-pmd-devmap.patch
arch/x86/include/asm/pgtable.h
mm/mremap.c